<template>
	<el-dialog
		:visible="true"
		width="80%"
		top="10vh"
		:destroy-on-close="true"
		class="rempadding"
		:before-close="handleClose"
	>
		<div slot="title" class="dialog-title">
			<span class="title-text" style="margin-right: 15px">
				{{ rowVal.proxyName }}
			</span>
		</div>
		<el-table
			v-if="tableData.length"
			size="mini"
			border
			height="600"
			show-summary
			:data="tableData"
			class="small-size-table"
			style="margin-bottom: 15px;"
			:header-cell-style="getRowClass"
			element-loading-spinner="el-icon-loading"
			:summary-method="
				(val) => handleVenueRow(val, rowVal.currency, subSummary)
			"
		>
			<el-table-column
				prop="venueName"
				align="center"
				:label="$t('report.venue')"
			></el-table-column>
			<el-table-column
				prop="totalNetAmount"
				align="center"
				:label="$t('report.total_net_amount')"
			>
				<template slot-scope="scope">
					{{ handleCurrency(rowVal.currency) }}
					{{
						handleNumber(rowVal.currency, scope.row.totalNetAmount)
					}}
				</template>
			</el-table-column>
			<el-table-column
				prop="venueRate"
				align="center"
				:label="$t('report.venue_rate')"
			>
				<template slot-scope="scope">
					{{ handlePercentage(scope.row.venueRate) }}
				</template>
			</el-table-column>
			<el-table-column
				prop="platformAmount"
				align="center"
				:label="$t('report.venue_fee')"
			>
				<template slot-scope="scope">
					{{ handleCurrency(rowVal.currency) }}
					{{
						handleNumber(rowVal.currency, scope.row.platformAmount)
					}}
				</template>
			</el-table-column>
		</el-table>
	</el-dialog>
</template>
<script>
import list from '@/mixins/list'
import summaryList from './summaryList'
export default {
	mixins: [list, summaryList],
	props: {
		rowVal: {
			type: Object,
			default: () => {}
		},
		closeDialog: {
			type: Function,
			default: () => {}
		}
	},
	data() {
		return {
			loading: false,
			tableData: [],
			subSummary: {}
		}
	},
	methods: {
		loadData() {
			this.loading = true
			this.$api
				.getProxyVenueFeeAPI(this.rowVal)
				.then((res) => {
					this.loading = false
					this.tableData = res?.data?.record || []
					this.subSummary = res?.data?.summary || {}
				})
				.catch(() => {
					this.loading = false
				})
		},
		handleClose() {
			this.closeDialog(false)
		}
	}
}
</script>
<style lang="scss" scoped></style>
